<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="/WEB-INF/aitag.tld" prefix="ai"%>  
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<jsp:include page="${ctx}/css_inc"></jsp:include>
<meta http-equiv="X-UA-Compatible" content="edge" />

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>触点管理</title>
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">

		<!-- Panel Other --> 
		<div class="row">

			<div class="col-sm-12">

				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>触点管理</h5>
					</div>
					<div class="ibox-content">
					 

						<div class="hr-line-dashed"></div>
						<div>

							<div>
								<button id="btnAdd" class="btn  btn-white " type="button">
									<i class="fa fa-plus"></i>&nbsp;添加
								</button>
								<!-- 
								<button id="btnDel" class="btn  btn-white " type="button">
									<i class="fa fa-trash-o"></i>&nbsp;删除
								</button>
								 -->
							</div>

							<table id="dataTable" data-height="452" data-mobile-responsive="true">

							</table>
						</div>
					</div>

				</div>
			</div>
			<!-- End Panel Other -->
		</div>
	</div>
	<jsp:include page="${ctx}/js_inc"></jsp:include>
	 
	<ai:DSStaticData fields="MARK_INFO_CHECK,TOPIC_IMPL_CLASS"/>
	
	<script type="text/javascript">
 
		 
		var layerIndex;
		

	 
		$('#btnDel').click(
				function() {
					var selected = $('#dataTable').bootstrapTable('getSelections');
					
				});
		$('#dataTable').bootstrapTable({
			columns : [  {
				field : 'criticalPointId',
				title : '编号',
				visible :false
			}, {
				field : 'criticalPointName',
				title : '触点' 
			}, {
				field : 'criticalPointStatus',
				title : '状态'
			}, {
				field : 'channelId',
				title : '渠道'
			}, {
				field : 'criticalPointType',
				title : '类型'
			}, {
				field : 'criticalPointDec',
				title : '描述'
			}, {
				field : 'effectiveDate',
				title : '生效日期'
			}, {
				field : 'expireDate',
				title : '失效日期'
			}, {
				field : 'createDate',
				title : '创建时间',
				visible :false
			}, {
				field : 'operate',
				title : '操作',
				width : '150px',
				halign : 'center',
				align : 'center',
				formatter : function(value, row, index) { 
					var html = '<a href="javascript:;" onclick="edit('+row.criticalPointId+')" title="编辑"><i class="fa fa-pencil text-navy"></i></a>&nbsp;'; 
					html +='<a href="javascript:;" onclick="del('+row.criticalPointId+')" title="删除"><i class="fa fa-trash-o text-danger"></i></a>'; 
					return html;
				}
			} ],
			classes :'table table-hover',
			uniqueId :'criticalPointId',
			idField :'criticalPointId',
			sortName : 'criticalPointId',
			sortOrder : 'asc',
			pagination : false, 
			sidePagination : 'server',
			clickToSelect : true,
			pageNumber : 1,
			pageSize : 10,
			pageList : [  10, 20, 50 ],
			queryParamsType : '',
			queryParams : function(params) {
 				return { 
				}
			},
			url : '${ctx}/contactmgn/point/queryPoint',
			groupBy : true,
			groupByField : 'catagoryId'
			
		});
		
		
		$('#btnAdd').click(
			function() {
				openLayer('触点新增','${ctx}/contactmgn/point/point');
			}
		);
		
		function edit(catagoryId){
			openLayer('触点修改','${ctx}/contactmgn/point/point?criticalPointId='+criticalPointId); 
		}
		
		function openLayer(title,url){
			layerIndex = layer.open({
				type : 2,
				title : title,
				btn : [ '确认', '关闭' ], 
				yes : function() {
					var object = $.serializeLayerIframeObject('#catagoryForm',layerIndex);
					var rtn = $.layerIframeObject('#catagoryForm',layerIndex).validate().form(); 
					object['parentId'] = $.layerIframeObject('#parentId',layerIndex).data('value');
						
					if(rtn === true){
						$.post('${ctx}/contactmgn/point/savePoint', object, 
				    			function (data) { 
					        		layer.close(layerIndex);
				    				if(data.success){ 
				    					 swal('保存成功！', '', 'success');
				    					 $('#dataTable').bootstrapTable('refresh');
				    				}else{
				    					 swal('保存失败！', data.msg, 'warning');
				    				}
				    			}
				    	); 
					}
				},
				 
				shadeClose : true,
				area : [ '800px', '500px' ],
				content : url
				});
		}

		function del(catagoryId){
			   swal({
			        title: '您确定要删除这条信息吗?',
			        text: '删除后将无法恢复，请谨慎操作！',
			        type: 'warning',
			        showCancelButton: true,
			        confirmButtonColor: '#ed5565', 
			        closeOnConfirm: false
			    }, function () {
			    	$.post('${ctx}/contactmgn/point/delPoint', { catagoryId: catagoryId }, 
			    			function (data) { 
			    				if(data.success){
			    					 swal('删除成功！', '您已经永久删除了这条信息。', 'success');
			    					 $('#dataTable').bootstrapTable('refresh');
			    				}else{
			    					 swal('删除失败！', data.msg, 'warning');
			    				}
			    			}
			    	); 
			    });
		}
	</script>
 
</body>

</html>
